Page({
  data: {
    shuju:{},
    current:0,
    params:null,
    goods_id:"",
    affiliate_id:""
  },
  bindPickerChange:function(e){
    
  },
  current1_FN:function(){
    this.setData({
      current:0
    })
  },
  current2_FN:function(){
    this.setData({
      current:1
    })
  },
  current3_FN:function(){
    this.setData({
      current:2
    })
  },
  change_FN:function(e){
    this.setData({
      current:e.detail.current
    })
  },
  onLoad:function(e){
    var self=this;
    this.data.goods_id=e.id;
    wx.request({
      url:"https://wx.ichelaba.com/htapi/index.php/store/sale/detail",
      data:{
        id:e.id
      },
      method:"GET",
      success:function(res){
        console.log(res)
        self.setData({
          affiliate_id:res.data.affiliate_id,
          shuju:res.data.detail,
          params:"https://wx.ichelaba.com"+res.data.params
        })
      }
    })
  },
  pay_FN:function(e){
    if(!wx.getStorageSync("user_id")){
      wx.showModal({
        title:"提示",
        content:"请登录",
        complete:function(e){
          if(e.confirm){
            wx.navigateTo({
              url:"/pages/login/login"
            })
          }
        }
      })
      return;
    }
    var self=this;
    wx.request({
      url:"https://wx.ichelaba.com/htapi/index.php/store/sale/loadOrder",
      data:{
        user_id:wx.getStorageSync("user_id"),
        id:self.data.goods_id,
        affiliate_id:self.data.affiliate_id
      },
      method:"GET",
      success:function(res){
        console.log(res);
        wx.showToast({
          title:"提交成功",
          mask:true,
          complete:function(){
            var data="img="+self.data.shuju.img+
                     "&price="+self.data.shuju.price+
                     "&product_name="+self.data.shuju.product_name+
                     "&product_id="+self.data.shuju.product_id+
                     "&desc="+self.data.shuju.desc+
                     "&user_contact="+res.data.user_contact+
                     "&user_mobile="+res.data.user_mobile+
                     "&shop_name="+self.data.shuju.shop_name+
                     "&affiliate_id="+self.data.affiliate_id;
            wx.navigateTo({
              url:"/pages/inPage_1/inPage_1?"+data
            })
          }
        })
      }
    })
  }
})